package p.ithorns.framework.minio.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.minio.ObjectWriteResponse;

/**
 * FileUploadResp
 *
 * @author liuhaitao
 * @date 2024/4/8 14:24
 * @since 1.0.0
 */
public class UploadResp {

    @JsonIgnore
    private ObjectWriteResponse response;

    private UploadResp() {
    }

    public static UploadResp wrap(ObjectWriteResponse response) {
        UploadResp resp = new UploadResp();
        resp.setResponse(response);
        return resp;
    }

    @Override
    public String toString() {
        if (null == response) {
            return "";
        }

        return "{" +
                "file:'" + response.object() + '\'' +
                ", bucket:'" + response.bucket() + '\'' +
                ", etag:'" + response.etag() + '\'' +
                ", version:'" + response.versionId() + '\'' +
                "}";
    }

    public ObjectWriteResponse getResponse() {
        return response;
    }

    public void setResponse(ObjectWriteResponse response) {
        this.response = response;
    }

}